/*
 * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
 *
 * https://www.mall4j.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */
package com.yami.shop.distribution.api.controller;

import com.yami.shop.common.config.Constant;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.distribution.common.dto.DistributionRecruitSetDto;
import com.yami.shop.distribution.common.vo.DistributionRecruitConfigVO;
import com.yami.shop.service.SysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @author yami
 */
@RestController
@RequestMapping("/p/distribution/recruit")
@Api(tags = "分销推广接口")
public class DistributionRecruitSetController {

    @Autowired
    private SysConfigService sysConfigService;
    @Autowired
    private MapperFacade mapperFacade;

    @GetMapping("/info")
    @ApiOperation(value = "获取店铺推广数据" ,notes = "根据店铺id获取")
    public ServerResponseEntity<DistributionRecruitSetDto> info(){
        DistributionRecruitConfigVO distributionRecruitConfigVO = sysConfigService.getSysConfigObject(Constant.DISTRIBUTION_RECRUIT_CONFIG, DistributionRecruitConfigVO.class);
        if (Objects.equals(0,distributionRecruitConfigVO.getState())) {
            distributionRecruitConfigVO.setContent("");
        }
        return ServerResponseEntity.success(mapperFacade.map(distributionRecruitConfigVO, DistributionRecruitSetDto.class));
    }
}
